﻿var MenuScene = cc.Scene.extend({
    heroSprite: null,
    aboutBtn: null,
    playBtn: null,   
    onEnter: function () {
        this._super();

        var size = cc.director.getWinSize();
        var bg = new BgLayer();
        this.addChild(bg);

        cc.spriteFrameCache.addSpriteFrames("res/graphics/texture.plist");
        this.heroSprite = new cc.Sprite("#welcome_hero.png");
        this.heroSprite.x = 400;
        this.heroSprite.y = 400;
        this.addChild(this.heroSprite);

        this.aboutBtn = new cc.MenuItemImage("#welcome_aboutButton.png", "#welcome_aboutButton.png", this._about);
        this.aboutBtn.x = 600;
        this.aboutBtn.y = 250;

        this.playBtn = new cc.MenuItemImage("#welcome_playButton.png", "#welcome_playButton.png", this._play);
        this.playBtn.x = 700;
        this.playBtn.y = 350;
       
        var soundBtn = new SoundButton();
        soundBtn.x = 40;
        soundBtn.y = size.height - 40;
        
        var menu = new cc.Menu(this.aboutBtn, this.playBtn, soundBtn);
        menu.x = 0;
        menu.y = 0;
        this.addChild(menu);
    },
    update:function(){
        console.log("update");
    },
    _about: function () {
        console.log("about");
    },
    _play: function () {
        console.log("play");
         cc.director.runScene(new PlayScene());
    }
});

var BgLayer = cc.Layer.extend({
    ctor: function () {
        this._super();
        var size = cc.director.getWinSize();
        var bgSprite = new cc.Sprite("res/graphics/bgWelcome.jpg");
        bgSprite.x = size.width / 2;
        bgSprite.y = size.height / 2;
        this.addChild(bgSprite);
    }

});